package com.itheima.tlias84.mapper;

import com.itheima.tlias84.dto.SelectAllDeptDTO;
import com.itheima.tlias84.entity.Dept;
import com.itheima.tlias84.utils.ResultUtil;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DeptMapper {
    @Select("select name , update_time from dept order by update_time desc ")
    List<SelectAllDeptDTO> selectAll();
    @Insert("insert into dept (name , update_time , create_time)values (#{d.name},#{d.updateTime},#{d.createTime})")
    int insertDept(@Param("d")Dept dept);


    @Delete("delete from dept where id = #{id}")
    int deleteById(@Param("id") Integer id);

    @Select("select id ,name  from dept where id=#{id}")
    SelectAllDeptDTO selectDeptById(@Param("id") Integer id);

    @Update("update dept set id =#{dp.id} ,  name = #{dp.name} , update_time = #{dp.updateTime} where id = #{dp.id}")
    int updateDeptById(@Param("dp") Dept dept);
//    @Delete("<script> </script>")
    int batchDelete(@Param("ids") List<Integer> ids);

}
